Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented smlua_text_utils_dialog_get #321

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EliteMasterEric
Copy link

@EliteMasterEric EliteMasterEric commented Sep 15, 2024

  • Implemented smlua_text_utils_dialog_get as a new Lua API function.
    • This function returns a table providing the information for a given line of dialog.
    • This allows for mods to create custom dialog interfaces, and for mods to perform inline replacements on the text of existing dialog (for example, replacing one name with another)
    • This function respects any previous replacements that have been performed using smlua_text_utils_dialog_replace.
  • Added a hard-coded limit of 1024 characters to smlua_text_utils_dialog_replace.
    • This should not conflict with the vanilla game, as the longest dialog is the Lakitu roughly 780 characters.
  • Added a Lua log warning to smlua_text_utils_dialog_replace which displays if the provided string exceeds the hard-coded length limit of 1024.
  • Added a Lua log warning to smlua_text_utils_dialog_replace which displays if the target dialog ID is invalid (outside the range of 1-170).

Copy link

@Squishy6094 Squishy6094 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The madman picked up C and Lua did it in 2 hours,, I plan on implementing this in Character Select for replacing dialog from "Mario" to your current character.

Copy link
Collaborator

@Isaac0-dev Isaac0-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limiting the dialog length may cause mod incompatibilities if a mod has a massive string.
I feel like it'd be best to use autogen instead of manually creating smlua_func_smlua_text_utils_dialog_get.
This would require exposing the struct DialogEntry, and allowing cobjects to handle strings.

@@ -40,4 +43,6 @@ void smlua_text_utils_castle_secret_stars_replace(const char* name);
void smlua_text_utils_extra_text_replace(s16 index, const char* text);
const char* smlua_text_utils_get_language(void);

void convert_string_sm64_to_ascii(char *strAscii, const u8 *str64);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert_string_sm64_to_ascii does not belong to smlua_text_utils.c
it is defined in level_info.c

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can correct this 👍

@EliteMasterEric
Copy link
Author

Limiting the dialog length may cause mod incompatibilities if a mod has a massive string.

The reason I limited dialogue length is because I had to convert the internal dialog string into a char* that could be passed to Lua; this requires using convert_string_sm64_to_ascii, which requires a fixed length buffer.

I feel like it'd be best to use autogen instead of manually creating smlua_func_smlua_text_utils_dialog_get. This would require exposing the struct DialogEntry, and allowing cobjects to handle strings.

I previously used autogen and then switched to manual in order to return a table containing all the values. I am new to Lua C and do not know how to expose a struct or allow cobjects to handle the strings being passed to Lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants